pub mod stdio;
pub mod tcp;

use std::pin::Pin;

use crate::{McpNotification, McpRequest, McpResponse, McpResult};
use futures::Stream;
use serde::{Deserialize, Serialize};
use async_trait::async_trait;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum McpMessage {
    Request(McpRequest),
    Response(McpResponse),
    Notification(McpNotification)
}

#[async_trait]
pub trait McpTransport: Send + Sync + 'static {
    /// Send a message over the transport
    async fn send(&self, message: McpMessage) -> McpResult<()>;
    
    /// Receive messages from the transport
    fn receive(&self) -> Pin<Box<dyn Stream<Item = McpResult<McpMessage>> + Send>>;
    
    /// Close the transport
    async fn close(&self) -> McpResult<()>;
}